package com.neuedu.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.neuedu.dao.FoodDao;
import com.neuedu.model.Food;

@Repository
public class FoodDaoImpl implements FoodDao {

	// 代码层级的整合spring+mybatis
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	@Override
	public int countFood() {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).countFood();
	}

	@Override
	public List<Food> findAll(Map<String, Object> map) {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).findAll(map);
	}

	@Override
	public int addFood(Food f) {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).addFood(f);
	}

	@Override
	public int updateFood(Food f) {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).updateFood(f);
	}

	@Override
	public List<Food> findList() {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).findList();
	}
	
	@Override
	public int deleteFood(int id) {
		// TODO 自动生成的方法存根
		return sqlSessionTemplate.getMapper(FoodDao.class).deleteFood(id);
	}
	
	//前台查询最新5条菜谱
		@Override
		public List<Food> findTop() {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findTop();
		}

		@Override
		public List<Food> findAllMenu() {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findAllMenu();
		}

		@Override
		public List<Food> findNewest() {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findNewest();
		}

		@Override
		public Food findFoodById(Food f) {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findFoodById(f);
		}

		@Override
		public List<Food> findFoodByMakeNo(Food  food) {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findFoodByMakeNo(food);
		}

		@Override
		public List<Food> findFoodByTypeNo(Food food) {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findFoodByTypeNo(food);
		}

		@Override
		public Food findFoodByName(Food f) {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findFoodByName(f);
		}

		@Override
		public List<Food> findFoodArticle(Food food) {
			// TODO Auto-generated method stub
			return sqlSessionTemplate.getMapper(FoodDao.class).findFoodArticle(food);
		}

}
